<?php
/**
 * 提现管理控制器
 * 
 * @author 王勇程 <laughskydragon@qq.com>
 */

namespace app\api\controller;

class Withdraw extends ApiBase
{
    /**
     * 获取提现配置
     */
    public function getConfig()
    {
        $data = $this->request->param();
        $result = $this->logicWithdraw->getConfig($data);
        return $this->apiReturn($result);
    }

    /**
     * 计算提现手续费
     */
    public function calculateFee()
    {
        $data = $this->request->param();
        $result = $this->logicWithdraw->calculateFee($data);
        return $this->apiReturn($result);
    }

    /**
     * 申请提现
     */
    public function apply()
    {
        $data = $this->request->param();
        $result = $this->logicWithdraw->apply($data);
        return $this->apiReturn($result);
    }

    /**
     * 获取用户提现记录
     */
    public function getUserWithdraws()
    {
        $data = $this->request->param();
        $result = $this->logicWithdraw->getUserWithdraws($data);
        return $this->apiReturn($result);
    }

    /**
     * 取消提现申请
     */
    public function cancel()
    {
        $data = $this->request->param();
        $result = $this->logicWithdraw->cancel($data);
        return $this->apiReturn($result);
    }

    /**
     * 获取提现状态
     */
    public function getStatus()
    {
        $data = $this->request->param();
        $result = $this->logicWithdraw->getStatus($data);
        return $this->apiReturn($result);
    }

    /**
     * 获取提现统计
     */
    public function getStats()
    {
        $data = $this->request->param();
        $result = $this->logicWithdraw->getStats($data);
        return $this->apiReturn($result);
    }

    /**
     * 提现综合页面数据
     * 包含：提现配置、用户余额、提现记录、提现统计
     */
    public function dashboard()
    {
        $data = $this->request->param();
        $result = $this->logicWithdraw->getDashboard($data);
        return $this->apiReturn($result);
    }

    /**
     * 过滤API参数
     */
    private function filterApiParams($data)
    {
        // 过滤不需要的参数
        unset($data['s'], $data['_url'], $data['_method']);
        return $data;
    }
}
